import java.io.IOException;
import java.io.InputStream;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.m2g.SVGImage;
import javax.microedition.m2g.ScalableGraphics;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;

public class ViewSVGImage extends MIDlet {
	//
	private Display display;
	private FetchSVGImage fetchSVGImage;

	//
	public ViewSVGImage() {
		// TODO Auto-generated constructor stub
		display = Display.getDisplay(this);
		this.fetchSVGImage = new FetchSVGImage();
	}

	protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
		// TODO Auto-generated method stub

	}

	protected void pauseApp() {
		// TODO Auto-generated method stub

	}

	protected void startApp() throws MIDletStateChangeException {
		// TODO Auto-generated method stub
		display.setCurrent(this.fetchSVGImage);
	}

}
class FetchSVGImage extends Canvas {
    private SVGImage map;
    private ScalableGraphics gc;

    public FetchSVGImage() {
        // Load map file
    	InputStream inputStream = getClass().getResourceAsStream("/weather.svg");
        try {
			map = (SVGImage) SVGImage.createImage(inputStream,null);
		} catch (IOException e) {
			e.printStackTrace();
		}
        gc = ScalableGraphics.createInstance();
    }
    public void paint(Graphics g) {
        gc.bindTarget(g);      //Bind the ScalableGraphics context to MIDP Graphics object.
        gc.render(0, 0, map);  //Render the SVG Image.
        gc.releaseTarget();    //Release the target
    }
 }
